home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / base-files.postinst < prev    next >
Encoding:
Text File  |  2007-04-12  |  4.4 KB  |  155 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. install_local_dir() {
  5.   if [ ! -d $1 ]; then
  6.     mkdir -p $1
  7.   fi
  8.   #chown root:staff $1 2> /dev/null || true
  9.   #chmod 2775 $1 2> /dev/null || true
  10. }
  11.  
  12. install_from_default() {
  13.   if [ ! -f $2 ]; then
  14.     cp -p $1 $2
  15.   fi
  16. }
  17.  
  18. install_directory() {
  19.   if [ ! -d /$1 ]; then
  20.     mkdir /$1
  21.     chown root:$3 /$1
  22.     chmod $2 /$1
  23.   fi
  24. }
  25.  
  26. preserve_directory() {
  27.   if [ -f /etc/base-files.create-$1 ]; then
  28.     install_directory $1 755 root
  29.     rm -f /etc/base-files.create-$1
  30.   fi
  31. }
  32.  
  33. if [ "$1" = "configure" ] && [ "$2" = "" ]; then
  34.   install_from_default /usr/share/base-files/nsswitch.conf /etc/nsswitch.conf
  35.   install_from_default /usr/share/base-files/dot.profile   /root/.profile
  36.   install_from_default /usr/share/base-files/dot.bashrc    /root/.bashrc
  37.   install_from_default /usr/share/base-files/profile       /etc/profile
  38.   install_from_default /usr/share/base-files/motd          /etc/motd
  39.   install_from_default /usr/share/base-files/networks      /etc/networks
  40.   install_directory srv       755 root
  41.   install_directory opt       755 root
  42.   install_directory etc/opt   755 root
  43.   install_directory var/opt   755 root
  44.   install_directory media     755 root
  45.   install_directory initrd    755 root
  46.   install_directory var/mail 2775 mail
  47.   if [ ! -L /var/spool/mail ]; then
  48.     ln -s ../mail /var/spool/mail
  49.   fi
  50.  
  51.   install_local_dir /usr/local
  52.   install_local_dir /usr/local/share
  53.   install_local_dir /usr/local/share/man
  54.   install_local_dir /usr/local/bin
  55.   install_local_dir /usr/local/games
  56.   install_local_dir /usr/local/lib
  57.   install_local_dir /usr/local/include
  58.   install_local_dir /usr/local/sbin
  59.   install_local_dir /usr/local/src
  60.   install_local_dir /usr/local/etc
  61.   ln -sf share/man /usr/local/man
  62. fi
  63.  
  64. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  65.   if [ ! -d /var/spool/mail ] && [ ! -L /var/spool/mail ]; then
  66.     if [ -f /etc/base-files.mailsymlink ]; then
  67.       ln -sf `cat /etc/base-files.mailsymlink` /var/spool/mail
  68.     else
  69.       install_directory var/spool/mail 2775 mail
  70.     fi
  71.   fi
  72.   if [ ! -L /var/mail ] && [ ! -d /var/mail ]; then
  73.     ln -sf spool/mail /var/mail
  74.   fi
  75.   install_from_default /usr/share/base-files/networks      /etc/networks
  76. fi
  77.  
  78. preserve_directory floppy
  79. preserve_directory cdrom
  80. preserve_directory initrd
  81.  
  82. if [ ! -f /etc/adjtime ]; then
  83.   echo "0.000000 1162000000 0.000000" > /etc/adjtime
  84.   echo "1162000000" >> /etc/adjtime
  85.   echo "UTC" >> /etc/adjtime
  86.   chmod 644 /etc/adjtime
  87. fi
  88.  
  89. if [ ! -f /var/run/utmp ]; then
  90.   echo -n>/var/run/utmp
  91. fi
  92. if [ ! -f /var/log/wtmp ]; then
  93.   echo -n>/var/log/wtmp
  94. fi
  95. if [ ! -f /var/log/btmp ]; then
  96.   echo -n>/var/log/btmp
  97. fi
  98. if [ ! -f /var/log/lastlog ]; then
  99.   echo -n>/var/log/lastlog
  100. fi
  101. chown root:utmp /var/run/utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  102. chmod 664 /var/run/utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  103.  
  104. if [ ! -d /var/lib/dpkg ]; then
  105.   mkdir -m 755 -p /var/lib/dpkg
  106.   chown root:root /var/lib/dpkg
  107. fi
  108. if [ ! -f /var/lib/dpkg/status ]; then
  109.   echo > /var/lib/dpkg/status
  110.   chmod 644 /var/lib/dpkg/status
  111.   chown root:root /var/lib/dpkg/status
  112. fi
  113.  
  114. if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then
  115.   install_from_default /usr/share/base-files/info.dir /usr/share/info/dir
  116.   chmod 644 /usr/share/info/dir
  117.   chown root:root /usr/share/info/dir
  118. fi
  119. rm -f /etc/base-files.mailsymlink
  120.  
  121. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  122.   if [ -f /etc/motd ]; then
  123.     oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
  124.     newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
  125.     if [ "$oldmd" != "$newmd" ]; then
  126.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  127.         awk 'NR <= 2' /etc/motd > /etc/motd.new
  128.         awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
  129.         mv /etc/motd /etc/motd.old
  130.         mv /etc/motd.new /etc/motd
  131.       fi
  132.     fi
  133.   fi
  134.  
  135.   if [ -f /etc/profile ]; then
  136.     md5=`md5sum /etc/profile | cut -f 1 -d\ `
  137.     if grep -qw "$md5" /usr/share/base-files/profile.md5sums; then
  138.         cp /usr/share/base-files/profile /etc/profile
  139.     fi
  140.   fi
  141. fi
  142.  
  143. if [ -f /var/lib/dpkg/info/base.list ]; then
  144.   :> /var/lib/dpkg/info/base.list
  145.   rm -f /var/lib/dpkg/info/base.conffiles
  146.   echo
  147.   echo "Note: You have the old \`base' package installed"
  148.   echo "It is very important that you do not try to remove this package"
  149.   echo "using dpkg. Please read /usr/share/doc/base-files/README.base to"
  150.   echo "get rid of the \`base' package completely in a safe way."
  151.   echo
  152.   echo -n "Press <Return> to continue "
  153.   read dummy
  154. fi
  155.